package com.mezz.bones.user.application.repository.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mezz.bones.user.application.mapper.ISysUserMapper;
import com.mezz.bones.user.application.repository.ISysUserRepository;
import com.mezz.bones.user.client.domain.entity.SysUser;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author mezz
 * @since 2025-07-09
 */
@Service
public class SysUserRepositoryImpl extends ServiceImpl<ISysUserMapper, SysUser> implements ISysUserRepository {

    @Override
    public SysUser findByUserId(String userId) {
        return this.getById(userId);
    }

    /**
     * DSTransactional会在DS切换数据源之后开启事务
     * @param userId
     * @return
     */
    @Override
    @DS("db2")
    @DSTransactional(rollbackFor = Exception.class)
    public SysUser findByUserIdWithSlaver(String userId) {
        return this.getById(userId);
    }
}
